package top.zhangjianyong.tools.function;

import top.zhangjianyong.tools.constant.WaBillMode;
import top.zhangjianyong.tools.entity.WaBill;

import java.math.BigDecimal;
import java.util.function.Function;

/**
 * @author ： zhangjianyong
 * @date ： 2022/7/23 7:52 PM
 */
public class WaBillModeFunctions {

    public final static Function<WaBill, BigDecimal> ZERO = waBill -> BigDecimal.ZERO;
    public final static Function<WaBill, BigDecimal> INCOME = waBill -> waBill.getAmt();
    public final static Function<WaBill, BigDecimal> PAY = waBill -> waBill.getAmt().negate();

    /**
     * 默认检查方法
     */
    public final static CheckBillFunction<WaBill, WaBillMode> DEFAULT_CHECK = ((waBill, waBillMode) ->
            waBillMode.platform.equals(waBill.getPlatform())
                    && waBillMode.inOrOut.equals(waBill.getInOrOut())
                    && waBillMode.type.equals(waBill.getType())
                    && waBillMode.state.equals(waBill.getState())
    );

    /**
     * true：非潘晓宇刷单
     */
    public final static CheckBillFunction<WaBill, WaBillMode> NO_PXY_CHECK = ((waBill, waBillMode) ->
            DEFAULT_CHECK.check(waBill, waBillMode)
                    && !"爱上时尚599".equals(waBill.getCounterparty())
                    && !"并不想取名臭傻逼".equals(waBill.getCounterparty())
                    && !"爱上**9".equals(waBill.getCounterparty())
    );

    /**
     * true：潘晓宇刷单
     */
    public final static CheckBillFunction<WaBill, WaBillMode> PXY_CHECK = ((waBill, waBillMode) ->
            DEFAULT_CHECK.check(waBill, waBillMode)
                    && ("爱上时尚599".equals(waBill.getCounterparty())
                    || "并不想取名臭傻逼".equals(waBill.getCounterparty())
                    || "爱上**9".equals(waBill.getCounterparty()))
    );

    /**
     * true：微信退款
     */
    public final static CheckBillFunction<WaBill, WaBillMode> WX_REFUND_TYPE_CHECK = ((waBill, waBillMode) ->
            waBillMode.platform.equals(waBill.getPlatform())
                    && waBillMode.inOrOut.equals(waBill.getInOrOut())
                    && waBill.getType().endsWith(waBillMode.type)
                    && waBillMode.state.equals(waBill.getState())
    );

    /**
     * true：非红包退款匹配
     */
    public final static CheckBillFunction<WaBill, WaBillMode> NO_HB_WX_REFUND_TYPE_CHECK = ((waBill, waBillMode) ->
            WX_REFUND_TYPE_CHECK.check(waBill, waBillMode)
                    && !waBill.getType().startsWith("转账")
                    && !waBill.getType().startsWith("微信红包")
    );
    //红包退款匹配
    public final static CheckBillFunction<WaBill, WaBillMode> HB_WX_REFUND_TYPE_CHECK = ((waBill, waBillMode) ->
            WX_REFUND_TYPE_CHECK.check(waBill, waBillMode)
                    && (waBill.getType().startsWith("转账")
                    || waBill.getType().startsWith("微信红包"))
    );

    public final static CheckBillFunction<WaBill, WaBillMode> WX_REFUND_TYPE_STATE_CHECK = ((waBill, waBillMode) ->
            waBillMode.platform.equals(waBill.getPlatform())
                    && waBillMode.inOrOut.equals(waBill.getInOrOut())
                    && waBill.getType().endsWith(waBillMode.type)
                    && waBill.getState().startsWith(waBillMode.state)
    );
    public final static CheckBillFunction<WaBill, WaBillMode> HB_WX_REFUND_TYPE_STATE_CHECK = ((waBill, waBillMode) ->
            WX_REFUND_TYPE_STATE_CHECK.check(waBill,waBillMode)
                    && (waBill.getType().startsWith("转账")
                    || waBill.getType().startsWith("微信红包"))

    );
    public final static CheckBillFunction<WaBill, WaBillMode> NO_HB_WX_REFUND_TYPE_STATE_CHECK = ((waBill, waBillMode) ->
            WX_REFUND_TYPE_STATE_CHECK.check(waBill,waBillMode)
                    && !waBill.getType().startsWith("转账")
                    && !waBill.getType().startsWith("微信红包")
    );
    /**
     * true：微信退款
     */
    public final static CheckBillFunction<WaBill, WaBillMode> WX_REFUND_STATE_CHECK = ((waBill, waBillMode) ->
            waBillMode.platform.equals(waBill.getPlatform())
                    && waBillMode.inOrOut.equals(waBill.getInOrOut())
                    && waBillMode.type.equals(waBill.getType())
                    && waBill.getState().startsWith(waBillMode.state)
    );
}
